<?php
/**
 * Created by littleU.
 * User: littleU
 * Date: 2021-02-03
 * Time: 10:51
 */

namespace app\api\service;

use app\api\model\About as AboutModel;

class About
{
    public static function getCompanyBasicInfo()
    {
        $obj = AboutModel::get(1);
        $data = $obj->hidden(['create_time','update_time'])->toArray();
        return json([
            'code' => config('code.success'),
            'data' => $data
        ]);
    }

    public static function setCompanyBasicInfo($data)
    {
        $id = $data['id'];
        try
        {
            $obj = new AboutModel();
            $obj->allowField(true)->save($data, ['id' => $id]);
        }
        catch (\Exception $ex)
        {
            return json([
                'code' => config('code.error'),
                'msg'  => $ex->getMessage()
            ]);
        }
        return json([
            'code' => config('code.success'),
            'msg'  => '编辑成功'
        ]);
    }
}